/**
 * 
 */
package expressions;

import tester.cobertura.Instrument;

/**
 * Title : Var
 * 
 * Javadoc Online at : http://www.ccs.neu.edu/home/ada2358/Doc/Satisfiability/index.html
 * @author Adam Blackwell
 * @version 1.0
 * @since April 2nd 2009
 */
@Instrument
public class Var extends BE implements Comparable<Var>{
  /* Fields */
  private String name;
  private boolean value;
  
  /**
   * @param name
   * @param value
   */
  public Var(String name, boolean value) {
    super();
    this.name = name;
    this.value = value;
  }
  
  /**
   * @return
   */
  public String getName() {
    return name;
  }
  
  /**
   * @param value
   */
  public void setValue(boolean value) {
    this.value = value;
  }

  /**
   * @return
   */
  public boolean isValue() {
    return value;
  }

  /* (non-Javadoc)
   * @see expressions.BE#accept(expressions.BEVisitor)
   */
  @Override public <R> R accept(BEVisitor<R> visit) {
    // TODO Auto-generated method stub
    return visit.forVar(this);
  }

  /* (non-Javadoc)
   * @see expressions.BE#hashCode()
   */
  @Override public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((name == null) ? 0 : name.hashCode());
    result = prime * result + (value ? 1231 : 1237);
    return result;
  }

  /* (non-Javadoc)
   * @see expressions.BE#equals(java.lang.Object)
   */
  @Override public boolean equals(Object obj) {
    if (this == obj)
      return true;
    if (getClass() != obj.getClass())
      return false;
    Var other = (Var) obj;
    if (name == null) {
      if (other.name != null)
        return false;
    } else if (!name.equals(other.name))
      return false;
    if (value != other.value)
      return false;
    return true;
  }

  @Override public int compareTo(Var other) {
    // TODO Auto-generated method stub
    return this.name.compareTo(other.name);
  }
}
